import { app } from 'electron'
import { PrismaClient } from '@prisma/client'
import path from 'path'

const dbPath = !app.isPackaged
    ? path.join(app.getAppPath(), 'prisma/todos.db')
    : path.join(process.resourcesPath, 'todos.db')

const db = new PrismaClient({
    datasources: {
        db: {
            url: `file:${dbPath}`
        }
    }
})

export default db